package org.agile4j.patterns.proxy.protect;

public class OrderProxy extends Order {

	public OrderProxy(String productName, int orderNum, String orderUser){
		super(productName, orderNum, orderUser) ;
	}
	
	@Override
	public void setProductName(String productName, String user) {
		if (user != null && user.equals(super.getOrderUser())) {
			super.setProductName(productName, user);
		} else {
			System.out.println(user + "用户没有权限.");
		}
	}

	@Override
	public void setOrderNum(Integer orderNum, String user) {
		if(user != null && user.equals(super.getOrderUser())){
			super.setOrderNum(orderNum, user);
		} else {
			System.out.println(user + "用户没有权限.");
		}
	}

	@Override
	public void setOrderUser(String orderUser, String user) {
		if(user != null && user.equals(super.getOrderUser())){
			super.setOrderUser(orderUser, user);
		} else {
			System.out.println(user + "用户没有权限.");
		}
	}

	@Override
	public String toString() {
		return "OrderProxy [getProductName()=" + getProductName() + ", getOrderNum()=" + getOrderNum() + ", getOrderUser()=" + getOrderUser() + "]";
	}
	
}
